<?php
class IndentItems {

	public static function add($data){
		return Db::get(__CLASS__)->insert($data)->exec() ;
	}

	public static function lastErr(){
		return Db::get(__CLASS__)->lastSql();
	}

	public static function getByIndent($indent_id){
		return Db::get(__CLASS__)->select()->where(array('indent_id'=>$indent_id))
				->order('sno ASC')->hkey('ware_id')->getAll();
	}

	static function deleteByIndent($indent_id){
		return Db::get(__CLASS__)->delete()->where(array('indent_id'=>$indent_id))->exec()
				&& Db::get(__CLASS__)->affectedRows() ? true : false;
	}
	
	public static function get($indent_id, $wareid){
		return Db::get(__CLASS__)->select()->where(array('indent_id'=>$indent_id,'ware_id'=>$wareid))->getOne();
	}

}
?>
